package com.sf.dlb.jpa.repository;

import com.sf.dlb.jpa.model.WalletExtractInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 提现信息表 Repository
 *
 * Created by jing.tan on 2018/5/21.
 */
@Repository
public interface WalletExtractRepository extends JpaRepository<WalletExtractInfo, Long> {
    /**
     * 根据用户ID-查询
     * @param userId
     * @param DelFlag
     * @return
     */
    List<WalletExtractInfo> findByUserIdAndDelFlagOrderByUpdateDateDesc(String userId, String DelFlag);
    /**
     * 根据提现流水号-查询
     * @param extractNumber
     * @param DelFlag
     * @return
     */
    WalletExtractInfo findByExtractNumberAndDelFlag(String extractNumber, String DelFlag);
    /**
     * 查询未成功的提现记录
     * @return
     */
    @Query(value = "SELECT * FROM `wallet_extract_info` a where a.extract_state='2' order by a.create_date desc LIMIT 0,1",nativeQuery = true)
    WalletExtractInfo quereyOneExxtractSuccess();
}